package dimension.starry.gui.screen;

import dimension.starry.StarryDimension;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.Identifier;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 150149
 */
@Environment(EnvType.CLIENT)
public class MainScreen {

    private static final List<Identifier> BACKGROUND_RESOURCE_LIST = new ArrayList<>();
    private static int time = 0;
    private static int i = 0;

    static {
        for (int i = 0; i <= 60; i++) {
            BACKGROUND_RESOURCE_LIST.add(new Identifier(
                StarryDimension.MOD_ID, "textures/gui/mainmenu/b" + i + ".png"));
        }
    }

    public static void renderBack(DrawContext drawContext) {
        if (time++ > 5) {
            if (++i > 60) {
                i = 0;
            }
            drawContext.drawTexture(
                BACKGROUND_RESOURCE_LIST.get(i), 0, 0, MinecraftClient.getInstance().getWindow().getScaledWidth(),
                MinecraftClient.getInstance().getWindow().getScaledHeight(), 0.0F, 0.0F, 16, 128, 16, 128
            );
            time = 0;
        }
    }

}
